package com.starsola.cloud.productserver.mapper;

import com.starsola.cloud.productapi.entity.Product;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
public class ProductMapper {

    private Map<Long, Product> maps = new HashMap<>();

    public ProductMapper() {
        for (int i = 1; i <= 10; i++) {
            long id = i;
            maps.put(id, new Product(id, "手机_0" + i, i * 8, i * 10));
        }
    }

    public List<Product> list() {
        return new ArrayList<>(maps.values());
    }

    public Product get(long id) {
        return maps.get(id);
    }


}
